<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="lui" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="u" uri="/iuie-tag"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<title>角色管理</title>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<link rel="shortcut icon" href="favicon.ico">
</head>
<lui:context/>
<u:View basePath="/res-system/role/" userJS="role" userCSS="role" delayLoadJs="false" res="jquery.ztree">
<body>
	<lui:boards>
		<lui:board width="70%" boardTitle="角色列表">
		    <!-- <dropList(id,emptyText),dropItem(value,text,view,find)>,<dropcode(id,name,codeType,showSelectAll,showSelectAllText,showSelectAllValue,onSuccess,readonly,onChange,className)> -->
			<form class='m-cust' id="findRoleFrm">
				<div class="form-horizontal">
					<div class="form-group">
						<div class="col-md-4 col-sm-4">
							<div class="input-group">
								<label for="roleName" class="input-group-addon">角色名称</label>
								<input name="roleName" id="roleName" type="text" class="form-control">
							</div>
						</div>
						<div class="col-md-4 col-sm-4">
							<div class="input-group"> 
								<label for="roleCode" class="input-group-addon">角色编码</label>
								<input name="roleCode" id="roleCode" type="text" class="form-control">
							</div>
						</div>
						<div class="col-md-4 col-sm-4">
							<div class="input-group"> 
								<label for="roleState" class="input-group-addon">角色状态</label>
								<select name="roleState" id="roleState" class="form-control">
								    <option value="">请选择</option>
								    <option value='1'>正常</option>
								    <option value='0'>禁用</option>
								</select>
							</div>
						</div>
					</div>
				</div>
				<div class="form-horizontal">
					<div class="form-group">
						<div class="col-md-12 col-sm-12">
							<div class="btn-group" id="buttonGro">
								<button type="button" class="btn btn-primary" onclick="SysRolePage.queryByCondition()"><i class='fa fa-fw fa-search'></i>查询</button>
								<button type="button" class="btn btn-info" onclick="SysRolePage.openRoleAddDialog()"><i class='fa fa-fw fa-plus'></i>新增</button>
								<button type="reset" class="btn btn-default"><i class='fa fa-fw fa-repeat'></i>重置</button>
							</div>
						</div>
					</div>
				</div>
			    <u:dropList id="drop_userState" emptyText="">
			        <u:dropItem value="1" text="正常" className="m-color-dark-green"/>
			        <u:dropItem value="0" text="禁用" className="m-color-dark-red"/>
			    </u:dropList>
			    
			    <u:dropListView id="dropView_oper">
			        <u:dropView name="edit" template="edit" onClick="SysRolePage.openRoleUpdateDialog" title="修改"/>
			        <u:dropView name="delete" template="delete" onClick="SysRolePage.deleteRole" title="删除"/>
			    </u:dropListView>
			    
			    <!--  根据角色名称模糊搜索、根据角色编码精确搜索 -->
				<u:dataSet id="roleSet" idField="roleId">
				    <u:dataField display="ID" name="roleId" visiable="false"/>
					<u:dataField display="角色名称" name="roleName" width="180px" align="left"/>
					<u:dataField display="角色编码" name="roleCode"/>
					<u:dataField display="状态" name="roleState" dropdown="drop_userState"/>
					<u:dataField display="描述" name="roleDesc" width="120px"/>
					<u:dataField display="操作" name="oper" dropView="dropView_oper" />
				</u:dataSet>
				<!-- 删除角色 -->
				<lui:ajax url="${ctx }/sys/role/delete/" id="deleteRoleAjax" type="post" onSuccess="SysRolePage.onDeleteSucc"/>
				<!-- 查询角色列表 -->
				<lui:ajax id="findRolesAjax" url="${ctx }/sys/role/findAllByPage" formQuery="#findRoleFrm" onSuccess="SysRolePage.onQuerySucc"/>
				<!-- 根据角色ID查询关联的菜单 -->
				<lui:ajax url="${ctx }/sys/role/findMenusById/" id="findMenusByRoleIdAjax" onSuccess="SysRolePage.onQueryMenusSucc"/>
				<lui:datatable id="roleDatatable" ajax="findRolesAjax" sortable="true" pagination="rolePagination" dataset="roleSet" checkable="true"
				    multiple="false" onItemClick="SysRolePage.onItemClick" cutLine="true" tip="true"/>
				<lui:pagination datatable="roleDatatable" id="rolePagination" pageSize="15" pageChoice="15" showPageChoice="false"/>
			</form>
		</lui:board>
		<lui:board width="30%" boardTitle="菜单树">
			<!-- 查询菜单 -->
	       <lui:ajax url="${ctx }/sys/menu/findAll" id="queryMenuTreeAjax" data="{'enabled':'1'}"/>
	       <!-- 保存角色菜单关联关系 -->
	       <lui:ajax url="${ctx }/sys/role/saveRelation/" id="saveRelationAjax" type="post" onSuccess="SysRolePage.saveRelationSucc" contentType="application/x-www-form-urlencoded"/>
	       <!-- 保存菜单 -->
	       <lui:oper-bar items="refresh,save" onRefresh="SysRolePage.refreshMenu" onSave="SysRolePage.saveRelation" />
	       <div style="margin-left:8px">
	           当前角色：<span class="m-color-dark-red" id="currentRole"></span>
	       </div>
	       <lui:tree nodeTitleKey="resName" nodeIdKey="resId" ajax="queryMenuTreeAjax" id="menuTree" checkable="true" silent="false"
	            parentIdKey="resPid" dataStructure="array" nodeNameKey="resName" nodeChildrenKey="children" maxLayer="3" expandAll="true"
	            />
		</lui:board>
	</lui:boards>
</body>
</u:View>
</html>